#include<bits/stdc++.h>
#define int long long
#define N 10
#define mod 998244353
using namespace std;

int Pow(int a, int n) {
	if(n == 0) return 1;
	if(n == 1) return a;
	int x = Pow(a, n / 2);
	if(n % 2 == 0) return x * x % mod;
	else return x * x % mod * a % mod;
}

int n, k, ans;
int a[N];
int cnt;
unordered_map<int, bool>vis;
bool use[N];


void dfs(int x) {
	if(x > n) {
		//a[1] = 2;
		//a[2] = 1;
		//for(int i = 1; i <= n; i++) cout << a[i] << " ";
		//cout << endl;
		vis.clear();
		int cnt = 0;
		for(int i = 1; i <= n; i++) {
			int res = 0;
			int x = i;
			memset(use, 0, sizeof(use));
			cnt = 0;
			while(1) {
				cnt++;
				res += x * x * x * x * x;
				x = a[x];
				if(x == i) {
					if(!vis[res]) ans = (ans + Pow(cnt, k)) % mod;
					vis[res] = 1;
					break;
				}
				if(use[x]) break;
				use[x] = 1;
			}
		}
		//exit(0);
		return;
	} 
	for(int i = 1; i <= n; i++) {
		a[x] = i;
		dfs(x + 1);
	}
}
signed main() {
	freopen("length.in", "r", stdin);
	freopen("length.out", "w", stdout);
	
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> k;
	dfs(1);
	cout << ans;
	return 0;
}

